home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 29 / general / stnetdev.doc < prev    next >
Text File  |  1985-11-19  |  15KB  |  324 lines

  1.  
  2.  
  3.                                 ST-NET
  4.                   Local Area Network for the Atari ST
  5.  
  6.                           Programmer's Guide
  7.  
  8.                              John S. DeMar
  9.  
  10.                        Quantum Microsystems, Inc.
  11.                               PO Box 179
  12.                           Liverpool, NY 13088
  13.                              315-451-7747
  14.  
  15. Introduction
  16.  
  17.    This document is a guide for Atari ST application programmers who wish 
  18. to  include  multi-user  functions  in  their  software.   All  Atari  ST 
  19. programmers  should  understand ST-Net's environment to insure  that  ST-
  20. Net's usage of the system does not interfere with their own.
  21.  
  22.    ST-Net offers two levels of networking functions to the user.  At  the 
  23. highest level,  the user may talk via keyboard to another user  ("Phone") 
  24. or exchange mail messages ("Mailbox"). Since these features are part of a 
  25. GEM desk accessory,  they are accessed through any GEM  application.  The 
  26. second  level is a transparent usage of peripherals physically  connected 
  27. to another computer on the network. For instance, one hard disk drive and 
  28. printer  may be accessed by several computers.  The  ST-Net  installation 
  29. program  lets  the  system  operator assign  priorities  to  devices  and 
  30. computers to customize the networks efficiency.
  31.  
  32.    For  the application programmer,  ST-Net offers high-level  multi-user 
  33. functions and low-level access to remote ST computers. All calls are made 
  34. through  the  68000 TRAP #9 instruction in  assembly  language.  Also,  a 
  35. library of these routines will be available for Megamax C at no charge.
  36.  
  37. 1.0  Electrical
  38.  
  39.      - 5V (6ma) current loop.
  40.      - Optically isolated.
  41.      - 31.25 K Baud serial digital data rate.
  42.      - 1 start bit, 8 data bits, 1 stop bit.
  43.      - Two-wire data in, two-wire data out, twisted pairs.
  44.      - Feedthrough at computer for power loss protection.
  45.  
  46. 2.0  Physical
  47.  
  48.      - Ring network, data-out to data-in of adjacent computers.
  49.      - Dual 5-pin DIN connectors at computers.
  50.      - Dual 4-pin RJ-11 modular interconnect.
  51.      - Adapter box for DIN to RJ-11 and protect at each computer.
  52.  
  53. 3.0  Protocol
  54.  
  55.    3.1  Command Frame
  56.  
  57.      - Byte-oriented command frame as follows:
  58.  
  59.     +-----+-----+-----+-----+-----+-----+------+------+-----+-----+
  60.     |DSTN#|RTRY#|SRCN#|COMND|ACNTH:ACNTL|ARG#1...ARG#n|CHCKH:CHCKL|
  61.     +-----+-----+-----+-----+-----+-----+------+------+-----+-----+
  62.        0     1     2     3     4     5   ...n bytes...  6+n   7+n
  63.  
  64.      - Minimum command frame size is 8 bytes (no arguments).
  65.      - Maximum command frame size is 1032 bytes (1024 argument bytes).
  66.  
  67.      - DSTN# ranges from 1 to 255 for upto 255 computers on the ring.
  68.         Destination node for command or zero if global (special case).
  69.      - RTRY# counts down to 0 for upto 255 attempts at command.
  70.         Zero signals that the command was aborted.
  71.      - SRCN# is the source node number for the command frame.
  72.          Zero is a special case for new node initialization.
  73.      - COMND requests one of the following operations:
  74.  
  75.           0  -->  Initialization request.  (See Net Table description.)
  76.           1  -->  Remote GEMDOS call.      (Trap #1)
  77.           2  -->  Remote AES/VDI call.     (Trap #2)
  78.           3  -->  Remote BIOS call.        (TRAP #13)
  79.           4  -->  Remote XBIOS call.       (TRAP #14)
  80.           5  -->  Remote Line-A call.      (A00X ops)
  81.        6-15  -->  Global Alerts.           
  82.          16  -->  Mail request.              
  83.          17  -->  Open Mailbox.            
  84.          18  -->  Close Mailbox.      
  85.          19  -->  Read Mail.           
  86.          20  -->  Write Mail.         
  87.          21  -->  Delete Mail.         
  88.          22  -->  List Bulletin Files.
  89.          23  -->  Post Bulletin.      
  90.          24  -->  Read Bulletin.      
  91.          25  -->  Kill Bulletin.     
  92.          26  -->  Ring Phone.              
  93.          27  -->  Phone string out.
  94.          28  -->  Phone string in.
  95.          29  -->  Hang-up Phone.
  96.          30  -->  BBS announce on.         
  97.          31  -->  BBS announce off.
  98.          32  -->  BBS conference string out.
  99.          33  -->  BBS conference string in.
  100.          34  -->  Status Poll             (See Net Table description.)
  101.       35-63  -->   (Future Expansion.)
  102.          64  -->  File Status
  103.          65  -->  Lock File    (NOT YET IMPLEMENTED)
  104.          66  -->  Unlock File  (NOT YET IMPLEMENTED)
  105.      67-127  -->   (Future Expansion.)
  106.          
  107.    3.1  Command Frame (con't)
  108.  
  109.      - ACNTH and ACNTL is the count in bytes of the argument string.
  110.          A command may have upto 1024 bytes of input parameters.
  111.      - CHCKH and CHCKL is the 16-bit CRC for the command frame.
  112.          If an error occurs, command frame is retransmitted with
  113.         RTRY# = RTRY# -1 until RTRY# is zero (failed operation).
  114.  
  115.    3.2  Data/Return Frame
  116.  
  117.      - Data/Return frames are strictly replies to Command frames
  118.          and are only sent when a return action is required.
  119.      - COMND is the same as for command frames except it has 128 added
  120.          to its value (highest bit on). This protects against
  121.          data frames being interpreted as command frames. 
  122.      - Data frames requiring more than 1024 bytes will have the true
  123.          remaining byte count in ACNTH/ACNTH. The actual byte count
  124.          will be 1024 until the last partial frame is sent. This allows
  125.          for some level of time sharing on the ring.
  126.  
  127. 4.0  Network Variables
  128.  
  129.    4.1 Net Table
  130.  
  131.      The Net Table holds a description of the network environment for
  132. each computer on the network, including your own. The table is built
  133. at boot time through the Initialization Request call and added to when
  134. ever an Initialization Request is received. The table begins with the
  135. entry for your computer and ends with the last computer to be added
  136. by the Initialization Request call. The Net Table description for your
  137. computer is kept in the STNET.SET file and is built by the NETBUILD.PRG
  138. program. Each entry in the Net Table has the following structure:
  139.  
  140.  struct NETNODE {
  141.      char node;          The node assigned during init, 0 = end.
  142.      char priority;      Priority level set in NETBUILD, 0 = high.
  143.      char printer;       Printer type on this node, 0 = none.
  144.      long drives;        The 'drvbits' accessible by other nodes.
  145.      char name[16];      Upto 16 char node-name set in NETBUILD.                
  146.      int  flags;         16 flags, first five used as follows:
  147.                               0 == Phone enabled.
  148.                               1 == Global Mailbox at this node.
  149.                               2 == Alerts are locked out.
  150.                               3 == AES/VDI locked out.
  151.                               4 == BIOS/XBIOS/LINE-A locked out.
  152.      char flavor;        Type of computer. 0 = ST/MIDI, 1=XE/LINK,
  153.   }                        3+ = RS-232 nodes, 128+ = DMA channel nodes.
  154.                            (Only ST/MIDI is implemented for now.)
  155.  
  156.      When a computer is turned off, that node remains in the Net Table
  157. until that node is accessed. When a command is not acknowledged after
  158. its maximum number of retries, the node is removed from the Net table.
  159. If a computer is powered down and rebooted, a duplicate copy of its
  160. description could be assigned in the Net Table until the old node is
  161. accessed and removed.
  162.       
  163.    4.2  Set-up File
  164.  
  165.      The STNET.SET file contains specific data describing the owners
  166. node configuration. This file is created or recreated by running the
  167. installation program called NETBUILD.PRG. The Set-up File contains the
  168. following information:
  169.  
  170.    NETNODE table_entry;  The structure described under Net Table.
  171.                          This info is declared to all other nodes.
  172.    int  retries[128];    List of the maximum retries for each command
  173.                            frame (one byte per command).
  174.    int  showbull;        Flag to show bulletins at powerup.
  175.    int  showmail;        Flag to show mail at power-up.
  176.    int  mailpath[];      Pathname for your mailbox. Null indicates
  177.                            that mail will be found on the global
  178.                            mail node path under your node name.
  179.  
  180.      This file is loaded at power-up and must be on the boot device's
  181. main directory as the filename STNET.SET. This file should not be
  182. modified without NETBUILD.PRG.
  183.  
  184. 5.0  Programming Libraries
  185.  
  186.    5.1  Transparent Functions
  187.  
  188.      ST-Net handles all accesses to floppy disks, hard disks and
  189. printers without special programming on the part of the application
  190. programmer. This 'transparent' operation allows existing programs to
  191. make use of the peripheral-sharing aspect of the network.
  192.  
  193.      The GEM Desk Accessory, STNET.ACC, installs the Phone/Mail
  194. features for use in any GEM application. Also, this accessory adds
  195. a Printer Spooler (background printing) and a Ramdisk (memory disk
  196. emulation). Information about other computers on the network is
  197. available by selecting this accessory.
  198.  
  199.    5.2  Application Functions
  200.  
  201.      The application programmer may use any of the ST-Net primitive
  202. commands to make multi-user, multi-computer programs. For instance,
  203. many users could enter data into a database system designed to make
  204. use of ST-Net. Or, several callers could have a conference on a 
  205. multi-line Bulletin Board System running on several Atari ST computers.
  206.  
  207.      All of the commands shown in the Command frame description are
  208. called via TRAP #9. Here's a brief description of each function
  209. showing the library function name and arguments for 'C':
  210.  
  211.   rgemdos(node,function,argptr)          REMOTE GEMDOS CALL
  212.   rvdi(node,function,argptr)             REMOTE VDI CALL
  213.   raes(node,function,argptr)             REMOTE AES CALL 
  214.   rbios(node,function,argptr)            REMOTE BIOS CALL
  215.   rxbios(node,function,argptr)           REMOTE XBIOS CALL
  216.     For each routine:
  217.       int node;                          Remote node number.
  218.       int function;                      Function/opcode number.
  219.       long argptr;                       Pointer to argument list.
  220.  
  221.  
  222.    5.2  Application Functions (con't)
  223.  
  224.   int net_init();         INITIALIZATION REQUEST
  225.                             Builds the Net Table. Returns -1 if init
  226.                           was successful or 0 if it failed.
  227.  
  228.   int net_alert(node,alert)   NETWORK GLOBAL ALERTS
  229.      int node;             0 = Error! Network is disconnected!
  230.      int alert;            1 = Error! That computer is disconnected!
  231.                            2 = The Network is busy!
  232.                            3 = That computer is busy!
  233.                            4 = Your printer is off line!
  234.                            5 = Your disk drive is not responding!
  235.                          6-9 = (Reserved)
  236.  
  237.   int net_mailreq(node)      MAIL REQUEST
  238.      int node;                 Returns -1 if Mailbox is active.
  239.                              Returns 0 if no mailbox for that node.
  240.  
  241.   int net_openmail(node)         OPEN MAILBOX
  242.      int node;                     Activates the mailbox file for the
  243.                                  following operations.
  244.  
  245.   int net_closemail(node)        CLOSE MAILBOX
  246.      int node;                     Close the mailbox file if opened.
  247.  
  248.   int net_readmail(node,psearch,pmsg)  READ MAIL
  249.      int node;                          Read a mail message using the
  250.     char *psearch;                    search criteria in string psearch.
  251.     char *pmsg;                       Save into memory at pmsg.
  252.  
  253.   int net_writemail(node,pmsg)   WRITE MAIL
  254.      int node;                     Write a mail message pointed to by
  255.     char *pmsg;                  pmsg. First line of message is subject.
  256.  
  257.   int net_delmail(node,psearch,pmsg)  DELETE MAIL
  258.      int node;                       Delete a mail message matching 
  259.     char *psearch;                 the subject in psearch. Oldest is
  260.                                    deleted if more that one matches.
  261.  
  262.   int net_listbull(node,pbuff)   LIST BULLETINS
  263.      int node;                     List the filenames of bulletins
  264.      int *pbuff;                 and save in 'pbuff'.
  265.  
  266.   int net_postbull(node,pfile)   POST BULLETIN
  267.      int node;                     Post a general bulletin saved in the
  268.     char *pfile;                 filename 'pfile'.
  269.  
  270.   int net_readbull(node,pname,pbuff)  READ BULLETIN
  271.      int node;                     Read the bulletin 'pname' and save
  272.     char *pname;                   into 'pbuff'. Returns the count of
  273.     char *pbuff;                   the bytes, 0 means end of bulletin.
  274.  
  275.    5.2  Application Functions (con't)
  276.  
  277.   int net_killbull(node,pname)  KILL BULLETIN
  278.      int node;                    Kills (Deletes) the bulletin in file
  279.     char *pname;                'pname'. Requires priority of zero.
  280.  
  281.   int net_phonecall(node)       RING PHONE
  282.      int node;                    Alerts a user with a phone call dialog.
  283.                                 Returns -1 if accepted, 0 if cancelled.
  284.  
  285.   int net_phoneout(node,pmsg)   PHONE MESSAGE OUT
  286.      int node;                    Send 'pmsg' intended as a line of
  287.     char *pmsg;                 conversation. Node 0 sends to all nodes.
  288.                                 Maximum length of 1024 bytes for 'pmsg'.
  289.  
  290.   int net_phonein(node,pmsg)    PHONE MESSAGE IN
  291.      int node;                    Receive phone message and/or status.
  292.     char *pmsg;                 Returns -1 for hangup or the length of
  293.                                 the message string saved in 'pmsg'.
  294.  
  295.   int net_phoneoff(node)        HANG-UP PHONE
  296.      int node;                    "Hang-up" your phone and notify the 
  297.                                 caller at 'node'. 0 means all nodes.
  298.  
  299.   int net_bbson(pname)          BBS ANNOUNCE LOG ON
  300.     char *pname;                  For Bulletin Board software, tell
  301.                                 all nodes that a user has logged on
  302.                                 and is called 'pname'.
  303.  
  304.   int net_bbsoff();             BBS ANNOUNCE LOG OFF
  305.                                   For Bulletin Board software, tell
  306.                                 all nodes that your user logged off.
  307.  
  308.   int net_bbsout(node,pmsg)     BBS CONFERENCE MESSAGE OUT
  309.      int node;                    Send conference message in bulletin
  310.     char *pmsg;                 board software. Node 0 sends to all.
  311.  
  312.   int net_bbsin(node,pmsg)      BBS CONFERENCE MESSAGE IN
  313.      int node;                    Check for a conference message in
  314.     char *pmsg;                 bulletin board software. Message is
  315.                                 saved in 'pmsg' and returns the length
  316.                                 of message.
  317.  
  318.   int net_status(node,pnet)     CHECK NETWORK STATUS
  319.      int node;                    Copies the net table entry for 'node'
  320.  NETNODE *pnet;                 into 'pnet'. Also returns a -1 if the
  321.                                 node is busy or 0 if it is not.
  322.  
  323. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  324.